﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;

namespace Master
{
    class TotalinfoContext : TableServiceContext
    {
        public TotalinfoContext(string baseAddress,
            StorageCredentials credentials)
            : base(baseAddress, credentials)
        { 
        }

        public void Add(int blobNum, int range)
        {
            Totalinfo totalinfo = new Totalinfo();
            totalinfo.PartitionKey = "T";
            totalinfo.RowKey = System.Guid.NewGuid().ToString();
            totalinfo.blobNum = blobNum;
            totalinfo.range = range;

            this.AddObject("docinfo", totalinfo);
            this.SaveChanges();
        }

        public IQueryable<Totalinfo> Info
        {
            get
            {
                return this.CreateQuery<Totalinfo>("docinfo");
            }
        }

        public IQueryable<Totalinfo> Select()
        {
            var results = from m in this.Info where m.PartitionKey == "T"
                          select m;
            return results;
        }
    }
}
